#include <iostream>
using namespace std;

void merge(int *list1, int size1, int *list2, int size2, int * &result, int &size3) {
    int i=0, j=0, k=0;
    size3 = size1+size2;
    result = new int [size3];
	while(i<size1 && j<size2){
		if(list1[i] < list2[j]) 	result[k++] = list1[i++];
		else	result[k++] = list2[j++];
	}
	while(i != size1)
		result[k++] = list1[i++];
	while(j != size2)
		result[k++] = list2[j++];
}

int main() {
    int s1, s2, s3;
	int *v1=NULL;
	int *v2=NULL;
	int *v3=NULL;

	cin >> s1;
	v1 = new int [s1];
	for (int i=0; i<s1; i++) cin >> v1[i];
	cin >> s2;
	v2 = new int [s2];
	for (int i=0; i<s2; i++) cin >> v2[i];

    merge(v1, s1, v2, s2, v3, s3);

	for(int i=0; i<s3; i++) cout << v3[i] << " ";
	cout << endl;
	return 0;
}

